<!--
 * @Description: 订单支付页面
 * @Author: pdx
 * @Date: 2021-11-20 17:21:54
 * @LastEditors: pdx
 * @LastEditTime: 2021-11-27 13:36:27
 -->
<template>
  <div class="payOrder">
    <!-- 头部 -->
    <div class="payOrder-header">
      <div class="header-content">
        <p>
          <i class="el-icon-s-order"></i>
        </p>
        <p>支付</p>
      </div>
    </div>

    <!-- 支付方式 -->
    <div class="pay-goods">
      <p class="title">付款方式</p>
      <div class="pay-content">
        <div class="pay-check">
          <el-row :gutter="20">
            <el-col :span="1">
              <div style="height: 80px; text-align: center; line-height: 70px">
                <el-checkbox v-model="aliPay"></el-checkbox>
              </div>
            </el-col>
            <el-col :span="20">
              <img src="../assets/alipay/img.png" style="width: 183px; "></img>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>

    <div class="section-goods">
      <p class="title">商品</p>
      <div class="goods-list">
        <ul>
          <li v-for="item in order.orderItems" :key="item.orderSn">
            <div>
              <router-link :to="{ path: '/game/details', query: {id : item.gameId} }" target="_blank">
                <img style="width : 130px; height: 85px; border-radius: 10px" :src="item.gameDefImg" />
              </router-link>
            </div>
            <div class="pro-name">
              <router-link :to="{ path: '/game/details', query: {id : item.gameId} }" target="_blank">
                {{item.gameName}}
              </router-link>
            </div>
            <div class="pro-total">
              ￥{{item.realAmount}}元
            </div>
          </li>
        </ul>
      </div>
    </div>

    <div class="cart-bar">
      <div class="cart-bar-left">

        <p class="cart-total">
            共<span class="cart-total-num">{{ gameNums }}</span> 款游戏
        </p>
      </div>
      <div class="cart-bar-right">
          <span>
            <span class="total-price-title">应付：</span>
            <span class="total-price">{{ order.price }} 元</span>
          </span>
        <div class="btn-primary" @click="payOrder">
          确认并付款
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import order from "@/api/order/order";

export default {
  name: "payOrder",

  data() {
    return {
      orderSn: '',
      order: {
        orderItems: []
      },
      aliPay: true,  //支付方式
      payVo: {},
      gameNums: 0,
    }
  },

  created() {
    if (this.$route.query.orderSn != undefined) {
      this.orderSn = this.$route.query.orderSn
      this.getOrder(this.orderSn)
    }else {

    }
  },

  methods: {

    getOrder(orderSn) {
      order.getOrderInfo(orderSn)
      .then(result => {
        this.order = result.data
        this.gameNums = result.data.orderItems.length
      })
    },

    payOrder() {
      let orderSn = this.order.orderSn
      if (orderSn == null || orderSn == '') {
        this.$message({
          type: 'error',
          message: '订单号错误'
        })
        return
      }
      let href = "http://localhost:88/api/thirdparty/thirdparty/aliPay/" + orderSn
      window.window.top.location.href = href
    }
  }
}
</script>

<style scoped>
.payOrder {
  background-color: #ffffff;
  padding-bottom: 20px;
}
/* 头部CSS */
.payOrder .payOrder-header {
  background-color: #fff;
  border-bottom: 2px solid #ff6700;
  margin-bottom: 20px;
}
.payOrder .payOrder-header .header-content {
  width: 1225px;
  margin: 0 auto;
  height: 80px;
}
.payOrder .payOrder-header .header-content p {
  float: left;
  font-size: 28px;
  line-height: 80px;
  color: #424242;
  margin-right: 20px;
}
.payOrder .payOrder-header .header-content p i {
  font-size: 45px;
  color: #ff6700;
  line-height: 80px;
}
/* 头部CSS END */

/* 付款方式 */
.pay-goods {
  width: 1225px;
  margin: 0 auto;
}

.pay-goods p.title {
  color: #ff6700;
  font-size: 25px;
  line-height: 40px;
}

.pay-check {
  display:inline;
}
/* 付款方式end */

/* 商品CSS */
.section-goods {
  width: 1225px;
  margin: 0 auto;
}
.section-goods p.title {
  color: #ff6700;
  font-size: 25px;
  line-height: 40px;
}
.section-goods .goods-list {
  padding: 5px 0;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
}
.section-goods .goods-list li {
  width: 1225px;
  height: 80px;
  padding: 10px 0;
  color: #ffffff;
  overflow: hidden;
}
.section-goods .goods-list li img {
  float: left;
  width: 150px;
  height: 70px;
  border-radius: 10px;
  margin-right: 10px;
}
.section-goods .goods-list li .pro-name {
  float: left;
  width: 650px;
  line-height: 70px;
}
.section-goods .goods-list li .pro-status {
  float: left;
  width: 99px;
  height: 30px;
  color: red;
  text-align: center;
  line-height: 30px;
}
.section-goods .goods-list li .pro-total {
  float: left;
  width: 190px;
  text-align: center;
  color: #ff6700;
  line-height: 70px;
}
/* 商品及优惠券CSS END */

/* 购物车底部导航条CSS */
.cart-bar {
  width: 1225px;
  margin: 0 auto;
  line-height: 50px;
  padding-bottom: 20px;
}

.cart-bar .cart-bar-left {
  text-align: right;
}

.cart-bar .cart-bar-left a:hover {
  color: #ff6700;
}

.cart-bar .cart-bar-left .cart-total {
  color: #757575;
}

.cart-bar .cart-bar-left .cart-total-num {
  color: #ff6700;
}

.cart-bar .cart-bar-right {
  float: right;
}

.cart-bar .cart-bar-right .total-price-title {
  color: #ff6700;
  font-size: 14px;
}

.cart-bar .cart-bar-right .total-price {
  color: #ff6700;
  font-size: 30px;
}

.cart-bar .cart-bar-right .btn-primary {
  float: right;
  width: 200px;
  text-align: center;
  font-size: 18px;
  margin-left: 50px;
  background: #ff6700;
  cursor: pointer;
  color: #fff;
}

.cart-bar .cart-bar-right .btn-primary-disabled {
  float: right;
  width: 200px;
  text-align: center;
  font-size: 18px;
  margin-left: 50px;
  background: #e0e0e0;
  color: #b0b0b0;
}

.cart-bar .cart-bar-right .btn-primary:hover {
  background-color: #f25807;
}

/* 购物车底部导航条CSS END */
</style>